package com.yyysj.friend.controller;

import com.yyysj.common.core.constants.HttpConstants;
import com.yyysj.common.core.domain.Result;
import com.yyysj.common.core.domain.TableDataInfo;
import com.yyysj.friend.aspect.CheckUserStatus;
import com.yyysj.friend.domain.dto.ExamDTO;
import com.yyysj.friend.domain.dto.ExamQueryDTO;
import com.yyysj.friend.service.IUserExamService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/exam")
@RequiredArgsConstructor
public class UserExamController {

    private final IUserExamService userExamService;

    @CheckUserStatus
    @PostMapping("/enter")
    public Result<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token, @RequestBody ExamDTO examDTO) {
        return Result.build(userExamService.enter(token, examDTO.getExamId()));
    }

    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
//        List<ExamVO> examVOList = userExamService.list(examQueryDTO);
//        if (examVOList == null) {
//            return TableDataInfo.empty();
//        }
//        return TableDataInfo.success(examVOList, examVOList.size());
        return userExamService.list(examQueryDTO);
    }
}
